﻿using System;
using System.IO;
using System.Xml.Serialization;
using SIMA.Core.Security;
using SIMA.Core.Enums;

namespace SIMA.Core.Data.Entity
{
    [Serializable]
    public class XmlEntity
    {
        #region Fields

        private Profile pcUsuario;
        private DateTime fechaTransaccion;
        private Operations operacion;

        #endregion

        #region Properties

        public Profile PcUsuario
        {
            get { return pcUsuario; }
            set { pcUsuario = value; }
        }

        public DateTime FechaTransaccion
        {
            get { return fechaTransaccion; }
            set { fechaTransaccion = value; }
        }

        public Operations Operacion
        {
            get { return operacion; }
            set { operacion = value; }
        }

        #endregion

        #region Constructor

        public XmlEntity()
        {
            FechaTransaccion = DateTime.Now;
            PcUsuario = SecurityProgram.PcProfile;
        }

        #endregion

        #region Public Methods

        public string ToXml()
        {
            StringWriter strWritter = new StringWriter();
            XmlSerializer xml = new XmlSerializer(this.GetType());
            xml.Serialize(strWritter, this);
            return strWritter.ToString();
        }

        #endregion
    }
}
